package com.view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;

public class Home extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	// JmenuBar
	private JMenuBar jmb;
	// Jmenu "Hệ thống", "Danh mục", "Qly Kho", "Bán hàng", "Trợ giúp"
	private JMenu jmnSystem, jmnCatalog, jmnStore, jmnSell, jmnHelp;
	// JmenuItem 'login', 'thoát', 'nhà cung cấp', 'nhân viên', 'khách hàng',
	// hàng hóa, phiếu nhập, phiếu xuất, tồn kho, hóa đơn
	// bảo hành, about, help
	private JMenuItem jmiLogout, jmiExit, jmiSupplier, jmiEmployee, jmiCustomer,
			jmiProduct, jmiVotesIn, jmiVotesOut, jmiBill, jmiInventory,
			jmiWarranty, jmiAbout, jmiHelp;

	private JPanel contentPane;

	public static void main(String[] args) {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (ClassNotFoundException ex) {
			System.out.println(ex.toString());
		} catch (InstantiationException ex) {
			System.out.println(ex.toString());
		} catch (IllegalAccessException ex) {
			System.out.println(ex.toString());
		} catch (UnsupportedLookAndFeelException ex) {
			System.out.println(ex.toString());
		}
		EventQueue.invokeLater(new Runnable() {

			@Override
			public void run() {
				try {
					Home home = new Home();
					home.setVisible(true);
//					home.pack();
					home.setLocationRelativeTo(null);
				} catch (Exception e) {
					System.out.println(e.toString());
				}
			}
		});
	}

	public Home() {
		super("QUẢN LÝ CỦA HÀNG ĐIỆN THOẠI DI ĐỘNG");
		initComponents();
	}

	public void initComponents() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(300, 100, 550, 300);
		setSize(750,330);
		setResizable(false);
//		setBackground(new Color(1111));

		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		JLabel lblbg = new JLabel();
		lblbg.setIcon(new ImageIcon("image/bg2.jpg"));
		contentPane.add(lblbg, BorderLayout.CENTER);

		jmb = new JMenuBar();
		jmb.setMargin(new Insets(300, 300, 300, 300));
		jmb.setForeground(new Color(0, 51, 102));
		setJMenuBar(jmb);

		// add menu to menuBar.
		jmnSystem = new JMenu("Hệ Thống");
		jmnSystem.setMnemonic('H');
		jmnSystem.setFont(new Font("Courier New", Font.BOLD, 17));
		jmnSystem.setForeground(new Color(0, 51, 102));
		jmnCatalog = new JMenu("Danh Mục");
		jmnCatalog.setMnemonic('D');
		jmnCatalog.setFont(new Font("Courier New", Font.BOLD, 17));
		jmnCatalog.setForeground(new Color(0, 51, 51));
		jmnStore = new JMenu("Quản Lý Kho");
		jmnStore.setMnemonic('Q');
		jmnStore.setFont(new Font("Courier New", Font.BOLD, 17));
		jmnStore.setForeground(new Color(0, 51, 102));
		jmnSell = new JMenu("Quản Lý Bán Hàng");
		jmnSell.setMnemonic('L');
		jmnSell.setFont(new Font("Courier New", Font.BOLD, 17));
		jmnSell.setForeground(new Color(0, 51, 51));
		jmnHelp = new JMenu("Trợ Giúp");
		jmnHelp.setMnemonic('G');
		jmnHelp.setFont(new Font("Courier New", Font.BOLD, 17));
		jmnHelp.setForeground(new Color(0, 51, 102));
		jmb.add(jmnSystem);
		jmb.add(jmnCatalog);
		jmb.add(jmnStore);
		jmb.add(jmnSell);
		jmb.add(jmnHelp);

		// add menuItem to menu System.
		jmnSystem.add(jmiLogout = new JMenuItem("Đăng Nhập", 'L'));
		jmnSystem.add(jmiExit = new JMenuItem("Thoát", 'E'));

		// add menuItem to menu Catalog.
		jmnCatalog
				.add(jmiSupplier = new JMenuItem("Danh Mục Nhà Cung Cấp", 'N'));
		jmnCatalog.add(jmiEmployee = new JMenuItem("Danh Mục Nhân Viên", 'V'));
		jmnCatalog.add(jmiCustomer = new JMenuItem("Danh Mục Khách Hàng", 'K'));
		jmnCatalog.add(jmiProduct = new JMenuItem("Danh Mục Hàng Hóa", 'H'));

		// add menuItem to menu Store.
		jmnStore.add(jmiVotesIn = new JMenuItem("Quản Lý Phiếu Nhập", 'U'));
		jmnStore.add(jmiVotesOut = new JMenuItem("Quản Lý Phiếu Xuất", 'X'));
		jmnStore.add(jmiInventory = new JMenuItem("Quản Lý Tồn Kho"));

		// add menuItem to menu Sell.
		jmnSell.add(jmiBill = new JMenuItem("Hóa Đơn", 'D'));
		jmnSell.add(jmiWarranty = new JMenuItem("Bảo Hành"));

		// add menuItem to menu Help.
		jmnHelp.add(jmiAbout = new JMenuItem("About"));
		jmnHelp.add(jmiHelp = new JMenuItem("Help"));

		// Set keyboard accelerators
		jmiLogout.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
				ActionEvent.CTRL_MASK));
		jmiExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,
				ActionEvent.CTRL_MASK));
		jmiSupplier.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,
				ActionEvent.CTRL_MASK));
		jmiEmployee.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,
				ActionEvent.CTRL_MASK));
		jmiCustomer.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K,
				ActionEvent.CTRL_MASK));
		jmiProduct.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H,
				ActionEvent.CTRL_MASK));
		jmiBill.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D,
				ActionEvent.CTRL_MASK));
		jmiVotesIn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U,
				ActionEvent.CTRL_MASK));
		jmiVotesOut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,
				ActionEvent.CTRL_MASK));
		jmiHelp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));

		// set icon for menu item.
		jmiLogout.setIcon(new ImageIcon("image/logout.png"));
		jmiExit.setIcon(new ImageIcon("image/quit.png"));
		jmiEmployee.setIcon(new ImageIcon("image/employee.png"));
		jmiSupplier.setIcon(new ImageIcon("image/factory.png"));
		jmiCustomer.setIcon(new ImageIcon("image/customer.png"));
		jmiProduct.setIcon(new ImageIcon("image/product.png"));
		jmiVotesIn.setIcon(new ImageIcon("image/votes-up.png"));
		jmiVotesOut.setIcon(new ImageIcon("image/votes-down.png"));
		jmiInventory.setIcon(new ImageIcon("image/warehouse.png"));
		jmiBill.setIcon(new ImageIcon("image/bill.png"));
		jmiWarranty.setIcon(new ImageIcon("image/warranty.png"));
		jmiAbout.setIcon(new ImageIcon("image/about.png"));
		jmiHelp.setIcon(new ImageIcon("image/help.png"));

		//
//		UIManager.put("JMenuBar.background",new Color(0, 51, 204));
//		UIManager.put("JMenu.background", Color.GREEN);
//		UIManager.put("JMenuItem.background", Color.MAGENTA);

	}

}
